package com.example.springboot0507.config;

import com.example.springboot0507.entity.Dog;
import com.example.springboot0507.entity.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * @Author 王博
 * @DateTime 2025-05-07 08:22
 */
@Configuration
@ComponentScan(basePackages = "com.example")
public class AppConfig {
    @Bean(value = "user1")
    public User user() {
        User user = new User();
        user.setId(1L);
        user.setName("jobs");
        user.setAge(10);
        return user;
    }

    @Bean(value = "dog1")
    public Dog dog1(){
        System.out.println("dog1");
        Dog dog = new Dog();
        dog.setId(1);
        return dog;
    }

    @Bean(value = "dog2")
    @Primary
    public Dog dog2(){
        System.out.println("dog2");
        Dog dog = new Dog();
        dog.setId(2);
        return dog;
    }
}
